package com.isunland.managesystem.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.CompanyForumMyAnswer.MyAnswerDetail;
import java.util.List;

public class CompanyFroumMyAnswerAdapter extends ArrayAdapter<MyAnswerDetail> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2015-12-11 11:32:49 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvMyPublishType;
    public final TextView tvMyPublishTitle;

    private ViewHolder(LinearLayout rootView, TextView tvMyPublishType, TextView tvMyPublishTitle) {
      this.rootView = rootView;
      this.tvMyPublishType = tvMyPublishType;
      this.tvMyPublishTitle = tvMyPublishTitle;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvMyPublishType = (TextView) rootView.findViewById(R.id.tv_myPublish_type);
      TextView tvMyPublishTitle = (TextView) rootView.findViewById(R.id.tv_myPublish_title);
      return new ViewHolder(rootView, tvMyPublishType, tvMyPublishTitle);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_ompanyforum_myanswer_list, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    MyAnswerDetail item = getItem(position);

    vh.tvMyPublishType.setText(item.getDiscussContents());
    vh.tvMyPublishTitle.setText(item.getRegDate());

    return vh.rootView;
  }

  private LayoutInflater mInflater;

  // Constructors
  public CompanyFroumMyAnswerAdapter(Context context, List<MyAnswerDetail> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  public CompanyFroumMyAnswerAdapter(Context context, MyAnswerDetail[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }
}

